package org.witsoft.localmq.impl;

import org.witsoft.localmq.ConfigManager;

import java.io.File;

/**
 * @ClassName: DefaultMqConfigManager
 * @Description:
 * @Author: Colin
 * @Date: 2020/12/26 8:31 PM
 * @Version 1.0
 **/
public class DefaultConfigManager implements ConfigManager {

    @Override
    public File getDataDir() {
        String path = System.getProperty("user.dir") + "/local_mq";
        File file = new File(path);
        if(!file.exists()){
            file.mkdirs();
        }
        return file;
    }

    @Override
    public long getMaxSegmentFileSize() {
        return 134217728 ; // 128MB
    }

    @Override
    public int getBrokerQueueSize() {
        return Integer.MAX_VALUE;
    }

    @Override
    public int getBrokerThreads() {
        return (int)Math.ceil(Runtime.getRuntime().availableProcessors() / 2d);
    }

    @Override
    public int getBrokerQueueMaxDataSize() {
        return 0;
    }

    @Override
    public int getBrokerBatchSize() {
        return 30;
    }
}
